import axios from "axios"
import { globals } from "@/main"
const request = axios.create({
    // baseURL: serverUr,
    timeout: 30000
})
request.interceptors.request.use(config => {
    // 每次请求时动态读取 baseURL
    config.baseURL = globals?.$config?.serverUrl
    config.headers['Content-Type'] = 'application/json;charset=utf-8'
    return config
}, error => {
    return Promise.reject(error)
})
request.interceptors.response.use(response => {
    let res = response.data
    return res
}, error => {
    console.log('response error' + error)
    return Promise.reject(error)
})
export default request